import 'package:flutter/material.dart';
import 'package:gzmall_app/common/color_common.dart';

class AccountSafePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => AccountSafePageState();
}

class AccountSafePageState extends State<AccountSafePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _createAppBar(),
      body: Container(
        color: ColorCommon.grey2,
        child: ListView(children: <Widget>[
          _getSettingItem("修改登录密码", "建议你定期更改密码以保护账号安全", "", () {
            Navigator.of(context).pushNamed("/reset_password");
          }),
          _getSettingItem("修改手机号码", "若手机更换请尽快修改", "18507676759", () {
            Navigator.of(context).pushNamed("/reset_phone");
          }),
        ]),
      ),
    );
  }

  _createAppBar() {
    return AppBar(
      elevation: 0.0,
      title: Text("账号安全"),
      leading: IconButton(
        icon: Icon(Icons.arrow_back_ios),
        onPressed: () {
          Navigator.of(context).pop();
        },
      ),
    );
  }

  _getSettingItem(
      String title, String subTitle, String content, GestureTapCallback onTap) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        color: Colors.white,
        padding: const EdgeInsets.only(
            left: 10.0, right: 10.0, top: 20.0, bottom: 20.0),
        margin: const EdgeInsets.only(bottom: 1.0),
        child: Row(children: <Widget>[
          Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text(
                title,
                style: TextStyle(
                    fontSize: 20.0,
                    fontWeight: FontWeight.bold,
                    color: ColorCommon.black1),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 5.0),
                child: Text(
                  subTitle,
                  style: TextStyle(fontSize: 14.0, color: ColorCommon.grey6),
                ),
              ),
            ],
          ),
          Expanded(
            child: Text(
              content,
              textAlign: TextAlign.end,
              style: TextStyle(fontSize: 14.0, color: ColorCommon.grey6),
            ),
          ),
          Icon(Icons.arrow_right),
        ]),
      ),
    );
  }
}
